package com.yeziji.common.business.dataMessage.base;

import cn.hutool.core.util.StrUtil;
import com.yeziji.common.business.system.SystemConfigConvertor;
import com.yeziji.utils.NanoIdUtils;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;

/**
 * 平台唯一标识信息
 *
 * @author hwy
 * @since 2024/10/29 14:50
 **/
@Data
@Builder
@NoArgsConstructor
@AllArgsConstructor
public class PlatformUniqueInfo {
    /**
     * 本地唯一码
     */
    private String localCode;

    /**
     * 云端唯一码
     */
    private String cloudCode;

    public static PlatformUniqueInfo convertByConfigStr(final String configStr) {
        if (StrUtil.isBlank(configStr)) {
            return new PlatformUniqueInfo(NanoIdUtils.randomNaoId(16), null);
        }
        return SystemConfigConvertor.init(configStr).buildConfig(PlatformUniqueInfo.class);
    }
}
